package com.example.mydemo.companyNature.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.mydemo.companynature.entity.CompanyNature;
import com.example.mydemo.companynature.mapper.CompanyNatureMapper;
import com.example.mydemo.companyNature.service.ICompanyNatureService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CompanyNatureServiceImpl extends ServiceImpl<CompanyNatureMapper, CompanyNature> implements ICompanyNatureService {
    @Override
    public List<CompanyNature> select() {
        return list();
    }

    @Override
    public Map<Integer, String> idName() {
        LambdaQueryWrapper<CompanyNature> wrapper = new LambdaQueryWrapper<>();
        List<CompanyNature> companyNatures = this.list(wrapper);
        Map<Integer, String> map = new HashMap<>();
        for (CompanyNature companyNature : companyNatures) {
            map.put(companyNature.getId(), companyNature.getName());
        }
        return map;
    }
}
